import { assessAnalysisOverviewReleaseMedia } from '@/services/api/api-assess-week-culture-analysis';
import { ProCard } from '@ant-design/pro-components';
import { useAccess } from '@umijs/max';
import { Divider, Statistic } from 'antd';
import RcResizeObserver from 'rc-resize-observer';
import React, { useEffect, useState } from 'react';

interface AreaReleaseMediaOverviewProps {
  areaId: string;
  releaseTimes: Array<string>; //季度发布时间范围
}

const AreaReleaseMediaOverview: React.FC<AreaReleaseMediaOverviewProps> = ({
  areaId,
  releaseTimes,
}) => {
  const [responsive, setResponsive] = useState(false);
  const access = useAccess();

  const [overviewReleaseMediaData, setOverviewReleaseMediaDataState] =
    useState<AssessWeekCultureAnalysisData.OverviewReleaseMedia>();

  const loadData = async () => {
    const response = await assessAnalysisOverviewReleaseMedia({
      areaId: areaId,
      releaseTimes: releaseTimes,
    });

    if (response.code == 0) {
      setOverviewReleaseMediaDataState(response.data);
    }
  };

  useEffect(() => {
    loadData();
  }, []);

  return (
    <RcResizeObserver
      key="resize-observer"
      onResize={(offset) => {
        setResponsive(offset.width < 596);
      }}
    >
      <ProCard.Group ghost direction={responsive ? 'column' : 'row'}>
        <ProCard>
          <Statistic
            // title="发稿总量（篇/得分）"
            title="发稿总量（篇）"
            value={overviewReleaseMediaData?.releaseMediaCount}
            // suffix={`/ 暂未计算分值`}
          />
        </ProCard>
        <Divider type={responsive ? 'horizontal' : 'vertical'} />
        <ProCard>
          <Statistic
            // title="中央媒体（篇/得分）"
            title="中央媒体（篇）"
            value={overviewReleaseMediaData?.releaseCentreMediaCount}
            // suffix="/ 暂未计算分值"
          />
        </ProCard>
        <Divider type={responsive ? 'horizontal' : 'vertical'} />
        <ProCard>
          <Statistic
            // title="市属媒体（篇/得分）"
            title="市属媒体（篇）"
            value={overviewReleaseMediaData?.releaseLocalMediaCount}
            // suffix="/ 暂未计算分值"
          />
        </ProCard>
      </ProCard.Group>
    </RcResizeObserver>
  );
};
export default AreaReleaseMediaOverview;
